import { BASE_URL, TIME_OUT } from './config'
import Request from './request'


const request = new Request({
  baseURL: BASE_URL,
  timeout: TIME_OUT,
  interceptors: {
    requestSuccessFn: (config) => {
      // 检查请求 URL 是否为登录请求
      if (!config.url?.endsWith('/login')) {
        // config.headers!.token = localCache.getCache(LOGIN_TOKEN)
      }
      if (config.url?.endsWith('/upload')) {
        config.headers!['Content-Type'] = 'multipart/form-data'
      }
      return config
    }
  }
})

export default request
